home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / dbus < prev    next >
Encoding:
Text File  |  2011-06-12  |  2.8 KB  |  123 lines

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          dbus
  4. # Required-Start:    $remote_fs $syslog
  5. # Required-Stop:     $remote_fs $syslog
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:
  8. # Short-Description: D-Bus systemwide message bus
  9. # Description:       D-Bus is a simple interprocess messaging system, used
  10. #                    for sending messages between applications.
  11. ### END INIT INFO
  12. # -*- coding: utf-8 -*-
  13. # Debian init.d script for D-BUS
  14. # Copyright ┬⌐ 2003 Colin Walters <walters@debian.org>
  15. # Copyright ┬⌐ 2005 Sjoerd Simons <sjoerd@debian.org>
  16.  
  17. set -e
  18.  
  19. DAEMON=/usr/bin/dbus-daemon
  20. UUIDGEN=/usr/bin/dbus-uuidgen
  21. UUIDGEN_OPTS=--ensure
  22. NAME=dbus
  23. DAEMONUSER=messagebus
  24. PIDDIR=/var/run/dbus
  25. PIDFILE=$PIDDIR/pid
  26. DESC="system message bus"
  27.  
  28. test -x $DAEMON || exit 0
  29.  
  30. . /lib/lsb/init-functions
  31.  
  32. # Source defaults file; edit that file to configure this script.
  33. PARAMS=""
  34. if [ -e /etc/default/dbus ]; then
  35.   . /etc/default/dbus
  36. fi
  37.  
  38. create_machineid() {
  39.   # Create machine-id file
  40.   if [ -x $UUIDGEN ]; then
  41.     $UUIDGEN $UUIDGEN_OPTS
  42.   fi
  43. }
  44.  
  45. start_it_up()
  46. {
  47.   if [ ! -d $PIDDIR ]; then
  48.     mkdir -p $PIDDIR
  49.     chown $DAEMONUSER $PIDDIR
  50.     chgrp $DAEMONUSER $PIDDIR
  51.   fi
  52.  
  53.   if ! mountpoint -q /proc/ ; then
  54.     log_failure_msg "Can't start $DESC - /proc is not mounted"
  55.     return
  56.   fi
  57.  
  58.   if [ -e $PIDFILE ]; then
  59.     if $0 status > /dev/null ; then
  60.       log_success_msg "$DESC already started; not starting."
  61.       return
  62.     else
  63.       log_success_msg "Removing stale PID file $PIDFILE."
  64.       rm -f $PIDFILE
  65.     fi
  66.   fi
  67.  
  68.   create_machineid
  69.  
  70.   log_daemon_msg "Starting $DESC" "$NAME"
  71.   start-stop-daemon --start --quiet --pidfile $PIDFILE \
  72.     --user $DAEMONUSER --exec $DAEMON -- --system $PARAMS
  73.   log_end_msg $?
  74. }
  75.  
  76. shut_it_down()
  77. {
  78.   log_daemon_msg "Stopping $DESC" "$NAME"
  79.   start-stop-daemon --stop --retry 5 --quiet --oknodo --pidfile $PIDFILE \
  80.     --user $DAEMONUSER
  81.   # We no longer include these arguments so that start-stop-daemon
  82.   # can do its job even given that we may have been upgraded.
  83.   # We rely on the pidfile being sanely managed
  84.   # --exec $DAEMON -- --system $PARAMS
  85.   log_end_msg $?
  86.   rm -f $PIDFILE
  87. }
  88.  
  89. reload_it()
  90. {
  91.   create_machineid
  92.   log_action_begin_msg "Reloading $DESC config"
  93.   dbus-send --print-reply --system --type=method_call \
  94.             --dest=org.freedesktop.DBus \
  95.             / org.freedesktop.DBus.ReloadConfig > /dev/null
  96.   # hopefully this is enough time for dbus to reload it's config file.
  97.   log_action_end_msg $?
  98. }
  99.  
  100. case "$1" in
  101.   start)
  102.     start_it_up
  103.   ;;
  104.   stop)
  105.     shut_it_down
  106.   ;;
  107.   reload|force-reload)
  108.     reload_it
  109.   ;;
  110.   restart)
  111.     shut_it_down
  112.     start_it_up
  113.   ;;
  114.   status)
  115.     status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
  116.     ;;
  117.   *)
  118.     echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|status}" >&2
  119.     exit 2
  120.   ;;
  121. esac
  122.  
  123.